<%@ page import="java.sql.DriverManager" %>
<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.PreparedStatement" %><%--
  Created by IntelliJ IDEA.
  User: 吧
  Date: 2020/12/1
  Time: 14:28
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>修改教师信息</title>
</head>
<body>

</body>
<%
    int ses=Integer.parseInt(session.getAttribute("ID").toString());

    Class.forName("com.mysql.jdbc.Driver");
    String url="jdbc:mysql://localhost:3306/lixiuying";
    Connection connection= DriverManager.getConnection(url,"root","root");
    String sql="update teacher set id=?, name=?, age=?,sex=?,tel=?,email=?,address=? where id=?";
    PreparedStatement pstm=connection.prepareStatement(sql);
    pstm.setInt(1,Integer.parseInt(request.getParameter("UpdateId")));
    pstm.setString(2,request.getParameter("UpdateserName"));
    pstm.setInt(3,Integer.parseInt(request.getParameter("UpdateAge")));
    pstm.setInt(4,Integer.parseInt(request.getParameter("UpdateSex")));
    pstm.setString(5,request.getParameter("UpdateserTel"));
    pstm.setString(6,request.getParameter("UpdateEmail"));
    pstm.setString(7,request.getParameter("UpdateAddress"));
    pstm.setInt(8,ses);
    int count=pstm.executeUpdate();
    if(count>0)
    {
        out.print("<h2>操作成功,即将返回教师信息页面</h2>");
        response.setHeader("refresh","3,url=SelectNews.jsp");
    }
    else
    {
        out.print("<h2>操作失败，即将返回教师信息页面</h2>");
        response.setHeader("refresh","3,url=SelectNews.jsp");
    }

%>
</html>
